/*
 * Copyright (c)  2015~2020, xforceplus
 * All rights reserved.
 * Project:datacare-orm
 * Id: PageQueryTag.java   2020-10-10 21-45-48
 * Author: Evan
 */
package cn.datacare.orm.engine.tag;

import cn.datacare.orm.query.PageQuery;
import org.beetl.core.tag.Tag;

import java.io.IOException;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: 2015~2020
 * </p>
 * <p>
 * Company/Department: xforceplus
 * </p>
 *
 * @author Evan
 * <b>Creation Time:</b> 2020-10-10 21-45-48
 * @since V1.0
 */
public class PageQueryTag extends Tag {
    /***
     * SQL Count Function :{@value}
     */
    protected static final String SQL_COUNT_FUN = "count(1)";

    /**
     * 配置信息
     */
    @Override
    public void render() {
        Object o = ctx.getGlobal(PageQuery.PAGE_FLAG);
        if (o == Boolean.TRUE) {
            try {
                this.bw.writeString(SQL_COUNT_FUN);
            } catch (IOException e) {
                //不可能发生
                e.printStackTrace();
            }

        } else {
            this.doBodyRender();

        }
    }
}
